<!DOCTYPE html>
<html lang="en"
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
    .message{
        color: black;
    }
    .wrong{
        
        color: red;
    }
    .true{
       color: green;
    }
</style>
</head>
<body>
    <input type="password">
    <button>确定</button>
    <p class="message">请输入6-16位的密码</p>
    
    <script>
        var input=document.querySelector("input");
        var btn=document.querySelector("button");
        var msg=document.querySelector(".message")
       input.onblur=function(){
            if(this.value.length<6||input.value.length>16){
                msg.className="message wrong";
                msg.innerHTML="你输入的位数不对要求6-16位";
                
            }
            else{
                msg.className="message true";
                msg.innerHTML="你输入的位数正确";
            }
        }
    </script>
</body>
</html>